package com.yfbao.horizon.docker.controller;

import com.yfbao.horizon.docker.service.PermissionUpdateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/permission")
@Slf4j
public class ActionPermissionController {
    @Autowired
    private PermissionUpdateService permissionUpdateService;

    @GetMapping("count")
    public Integer getRulesNum(){
        return permissionUpdateService.getCount();
    }

    @GetMapping("/tables/count")
    public String getTablesNum(){
        return permissionUpdateService.findTablesCount();
    }

    @GetMapping("/update/part/{num}")
    public Integer updateRuleDataPartion(@PathVariable(value = "num") Integer num){
        return permissionUpdateService.updateEntity(num);
    }

    @GetMapping("/update/part")
    public Integer updateRuleDataPartionDefault(){
        return permissionUpdateService.updateEntity(50*10000);
    }

    @GetMapping("/update/all")
    public Integer updateRuleDataAll(){
        return permissionUpdateService.updateEntity(0);
    }
}
